/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface;

import Common.Item;
import Controller.POSController;
import java.awt.*;
import java.util.ArrayList;
import javax.swing.*;

/**
 *
 * @author satkins
 */
public class POSGui {

    private JFrame frame;
    private Container pane;
    private POSController posControl;

    public POSGui(){
        posControl = new POSController();
    }

    public void build(){
        frame = new JFrame();
        frame.setTitle("DigiStore");
        frame.setBackground(Color.white);
        frame.setSize(850, 650);

        // get the content pane and set layout to null
        pane = frame.getContentPane();
        pane.setLayout(new GridLayout());
       // Dimension windowSize = new Dimension(800,600);
       // pane.setPreferredSize(windowSize);

        posControl.LogIn(null, null);
        WelcomeScreen();

        // set conditions of the frame
        frame.pack();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation(((int)screenSize.getWidth()/2)-frame.getWidth()/2, ((int)screenSize.getHeight()/2)-frame.getHeight()/2 );
        frame.setResizable(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public void LogInScreen(){
        LogIn login = new LogIn(this);
        login.setBounds(0, 0, 800, 600);
        pane.removeAll();
        pane.add(login);
        pane.validate();
        pane.repaint();
    }

    public void WelcomeScreen(){
        WelcomeScreen welcome = new WelcomeScreen(this);
        welcome.setBounds(0, 0, 800, 600);
        pane.removeAll();
        pane.add(welcome);
        pane.validate();
        pane.repaint();
    }

    public ArrayList<Item> getItems(){
        ArrayList<Item> Items;
        Items = posControl.getItems();
        return Items;
    }

    public boolean LogIn(String name, String password){
        return posControl.LogIn(name, password);
    }
}
